package com.example.kx005_rabbit;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        FrameLayout frameLayout = findViewById(R.id.my_layout);


        DogView dogView = new DogView(this);

        //触控时间
        dogView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {

                dogView.x=motionEvent.getX();
                dogView.y=motionEvent.getY();

                dogView.invalidate();//重绘


                return true;
            }
        });


        //


        frameLayout.addView(dogView);





    }
}